package com.openbravo.beans;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Paint;
import java.awt.RenderingHints;
import java.awt.Stroke;
import javax.swing.border.AbstractBorder;
import javax.swing.border.Border;

public class RoundedBorder extends AbstractBorder
{
  private static Border blackLine;
  private static Border grayLine;
  private static Border gradientBorder;
  protected Color colorBorder;
  protected Color colorgradient;
  protected int roundedRadius;
  protected float thickness;
  protected boolean filled;
  private float ftop;
  private float fbottom;
  private float ftopinset;
  private float fbottominset;

  public static Border createBlackLineBorder()
  {
    if (blackLine == null)
      blackLine = new RoundedBorder(Color.BLACK);
    return blackLine;
  }

  public static Border createGrayLineBorder()
  {
    if (grayLine == null)
      grayLine = new RoundedBorder(Color.GRAY);
    return grayLine;
  }

  public static Border createGradientBorder()
  {
    if (gradientBorder == null)
      gradientBorder = new RoundedBorder(Color.GRAY, 0.0F, 8, false, false);
    return gradientBorder;
  }

  public RoundedBorder(Color paramColor)
  {
    this(paramColor, Color.WHITE, 1.0F, 0, true, true);
  }

  public RoundedBorder(Color paramColor, float paramFloat)
  {
    this(paramColor, Color.WHITE, paramFloat, 0, true, true);
  }

  public RoundedBorder(Color paramColor, float paramFloat, int paramInt)
  {
    this(paramColor, Color.WHITE, paramFloat, paramInt, true, true);
  }

  public RoundedBorder(Color paramColor, float paramFloat, int paramInt, boolean paramBoolean1, boolean paramBoolean2)
  {
    this(paramColor, Color.WHITE, paramFloat, paramInt, paramBoolean1, paramBoolean2);
  }

  public RoundedBorder(Color paramColor1, Color paramColor2, float paramFloat, int paramInt, boolean paramBoolean1, boolean paramBoolean2)
  {
    this.colorBorder = paramColor1;
    this.colorgradient = paramColor2;
    this.thickness = paramFloat;
    this.roundedRadius = paramInt;
    this.filled = true;
    this.ftop = (paramBoolean1 ? 0.0F : paramFloat + paramInt);
    this.fbottom = (paramBoolean2 ? 0.0F : paramFloat + paramInt);
    this.ftopinset = (paramBoolean1 ? 0.0F : paramFloat);
    this.fbottominset = (paramBoolean2 ? 0.0F : paramFloat);
  }

  public void paintBorder(Component paramComponent, Graphics paramGraphics, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
    Object localObject = localGraphics2D.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
    Stroke localStroke = localGraphics2D.getStroke();
    Paint localPaint = localGraphics2D.getPaint();
    localGraphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    float f = this.thickness;
    if (this.filled)
    {
      if (paramComponent.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT)
        localGraphics2D.setPaint(new GradientPaint(0.0F, 0.0F, paramComponent.getBackground(), paramInt3, 0.0F, this.colorgradient));
      else
        localGraphics2D.setPaint(new GradientPaint(0.0F, 0.0F, this.colorgradient, paramInt3, 0.0F, paramComponent.getBackground()));
      localGraphics2D.fillRoundRect((int)(paramInt1 + this.thickness), (int)(paramInt2 + this.thickness - this.ftop), (int)(paramInt3 - this.thickness - this.thickness), (int)(paramInt4 - this.thickness - this.thickness + this.ftop + this.fbottom), (int)(this.roundedRadius * 2 - f), (int)(this.roundedRadius * 2 - f));
    }
    if (this.thickness > 0.0F)
    {
      localGraphics2D.setStroke(new BasicStroke(this.thickness));
      localGraphics2D.setPaint(this.colorBorder);
      localGraphics2D.drawRoundRect(paramInt1, (int)(paramInt2 - this.ftop), (int)(paramInt3 - this.thickness), (int)(paramInt4 - this.thickness + this.ftop + this.fbottom), this.roundedRadius * 2, this.roundedRadius * 2);
    }
    localGraphics2D.setPaint(localPaint);
    localGraphics2D.setStroke(localStroke);
    localGraphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, localObject);
  }

  public Insets getBorderInsets(Component paramComponent)
  {
    return new Insets((int)(0.5D + this.thickness - this.ftopinset), (int)(0.5D + this.thickness + this.roundedRadius), (int)(0.5D + this.thickness - this.fbottominset), (int)(0.5D + this.thickness + this.roundedRadius));
  }

  public Insets getBorderInsets(Component paramComponent, Insets paramInsets)
  {
    paramInsets.top = (int)(0.5D + this.thickness - this.ftopinset);
    paramInsets.left = (int)(0.5D + this.thickness + this.roundedRadius);
    paramInsets.bottom = (int)(0.5D + this.thickness - this.fbottominset);
    paramInsets.right = (int)(0.5D + this.thickness + this.roundedRadius);
    return paramInsets;
  }

  public Color getLineColor()
  {
    return this.colorBorder;
  }

  public float getThickness()
  {
    return this.thickness;
  }

  public boolean isFilled()
  {
    return this.filled;
  }

  public boolean isBorderOpaque()
  {
    return true;
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.beans.RoundedBorder
 * JD-Core Version:    0.6.0
 */